Skip to content

Implement Cosmos performance optimization, DAI, Redis cache, and maintenance tooling#1005

Merged
Bionic711 merged 14 commits into
Developmentfrom
feature/performanceimprovement2
Jul 7, 2026
Merged

Implement Cosmos performance optimization, DAI, Redis cache, and maintenance tooling#1005
Bionic711 merged 14 commits into
Developmentfrom
feature/performanceimprovement2

Conversation

@Bionic711

Copy link
Copy Markdown
Collaborator

Summary

This PR implements the phased SimpleChat Cosmos DB performance optimization program that started from the 0.250.001 baseline and now carries through the current 0.250.046 branch state.

The core goal is to reduce high-volume Cosmos reads, avoid repeated cross-partition list queries, suppress unnecessary settings container RU churn, and add operational visibility/maintenance tools without changing the source-of-truth document containers or Azure AI Search architecture.

Cosmos Performance Work

  • Added a shared low-churn cache foundation for app/settings-adjacent data, custom pages/navigation, and chat bootstrap payloads.
  • Hardened cache invalidation across group, public workspace, model endpoint, Control Center, and SimpleChat-native mutation paths.
  • Added user-scoped conversation list/feed/search caching with Redis-first behavior, source fallback, cache-version invalidation, and Admin Settings metrics.
  • Tuned mark-read behavior so normal conversation switching does not churn the conversation cache when unread state is already clear.
  • Preserved background chat-completion unread notifications after mark-read tuning.

Document Access Index

  • Added the document_access_index companion container as a read model for document list, tag list, legacy-count, and public/group/personal document visibility workloads.
  • Added write-through projection, deterministic scope-partitioned rows, projection repair state, repair backlog handling, and source fallback safety.
  • Added resumable backfill, repair reconciliation, schema-version readiness gates, and automatic app-maintenance execution.
  • Added shadow validation and rolling source-vs-projection diagnostics before read-path broadening.
  • Promoted DAI-backed document and tag list reads to the default read path with safety gates and source fallback.
  • Added DAI list parity fixes for pending shares, public workspace generated artifacts, exact/case-sensitive filters, legacy revision collapsing, and tag identity handling.

Redis, Maintenance, and Admin Visibility

  • Added Redis monitoring under Admin Settings > Scale, including runtime health, memory, hit rate, key counts, errors, and DAI cache hygiene metrics.
  • Added Redis Explorer for admin-only, read-only key browsing with sanitized previews and SimpleChat DAI version-marker resolution.
  • Added Redis-only read-through caching for DAI document/tag/legacy reads with scope-version invalidation and bounded TTLs.
  • Added DAI Redis version marker TTL hygiene so marker keys do not live indefinitely.
  • Added Cosmos maintenance support for expected composite-index comparison/apply and stale operational cache cleanup.
  • Added guarded Admin Settings action for applying missing Cosmos composite indexes.
  • Added Phase 9 support/runbook documentation for rebuilding caches, rebuilding DAI, cleaning stale operational cache docs, interpreting DAI fallback/cache metrics, and evaluating source fallback.

RU / Churn Fixes

  • Reduced idle settings container RU consumption by avoiding unrelated cache/version churn from routine settings writes, no-op autoscale checks, and status refreshes.
  • Made volatile chat bootstrap and conversation cache payloads Redis-only when Redis is unavailable, falling back to source queries instead of writing cache artifacts to Cosmos settings.
  • Added short-lived in-process DAI status caching and skipped disabled shadow-validation state reads.

Supporting PR / Merge Work

  • Merged latest origin/Development into the feature branch.
  • Preserved Development release-note entries for audio/FFmpeg support and anonymous notification polling fixes.
  • Added root requirements-dev.txt for local validation dependencies.
  • Added PR CodeQL workflow changes.
  • Fixed PR-readiness guardrail issue by routing conversation cache invalidation reads through the existing personal conversation ownership helper.
  • Updated functional/UI test fixtures after merge drift.

Validation

  • git diff --check
  • Python compile check for changed Python files
  • node --check for changed JavaScript files
  • python scripts/check_swagger_routes.py ...
  • XSS guardrail checks
  • Broken access control guardrail checks
  • Route policy coverage tests:
    • functional_tests/route_tests/test_route_blueprint_policy_inventory.py
    • functional_tests/route_tests/test_route_unauthenticated_policy_contract.py
    • functional_tests/route_tests/test_route_policy_test_coverage.py
  • Changed standalone functional tests: passed
  • Changed UI tests: 17 passed

Documentation

  • Updated docs/explanation/features/COSMOS_PERFORMANCE_OPTIMIZATION_PLAN.md
  • Added docs/explanation/features/REDIS_EXPLORER.md
  • Added/updated Cosmos performance fix documentation
  • Updated docs/explanation/release_notes.md
  • Updated current version to 0.250.046

Known Risks / Follow-Up

  • The PR includes a large multi-wave performance change set; reviewers should focus on DAI fallback safety, repair/backfill readiness gates, Redis cache invalidation, and settings-container write suppression.
  • Source document containers remain authoritative; DAI and Redis paths are optimized read paths with fallback behavior.
  • Live production RU improvement should be confirmed with App Insights/Cosmos metrics after deployment.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@Bionic711

Copy link
Copy Markdown
Collaborator Author

closes #1004

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@Bionic711 Bionic711 marked this pull request as ready for review July 7, 2026 21:28
@Bionic711 Bionic711 self-assigned this Jul 7, 2026
@Bionic711 Bionic711 merged commit 1906210 into Development Jul 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants